package com.wynet.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wynet.dao.UsersDao;
import com.wynet.entity.Users;
import com.wynet.service.intf.UsersService;
import com.wynet.vo.PageVo;
import com.wynet.vo.R;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UsersServiceImpl implements UsersService {

    @Resource
    private UsersDao dao;

    @Override
    public R add(Users users) {
        if (dao.add(users) > 0) {
            return R.ok();
        }else {
            return R.fail();
        }
    }

    @Override
    public PageVo queryPage(int page, int limit) {
        PageHelper.startPage(page, limit);
        PageInfo<Users> pageInfo = new PageInfo<>(dao.selectAll());
        return new PageVo(0,"OK",pageInfo.getTotal(),pageInfo.getList());
    }
}
